import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName } from '@/config/settings'

export async function login(data) {
  if (loginRSA) {
    data = await encryptedData(data)
  }
  return request({
    url: '/erp/auth/login',
    method: 'post',
    data,
  })
}



export function getUsersByDeletedFalse() {
  return request({
    url: '/erp/auth/usersByDeletedFalse',
    method: 'get'
  })
}

export function getUserInfo() {
  return request({
    url: '/erp/user/details',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/erp/auth/logout',
    method: 'post',
  })
}

export function register(data) {
  return request({
    url: '/erp/user/addUser',
    data,
    method: 'post',
  })
}

export function checkUser(data) {
  return request({
    url: '/erp/auth/checkUser',
    data,
    method: 'post',
  })
}

export function getAllList() {
  return request({
    url: '/erp/user/all',
    method: 'get'
  })
}

export function getList(data) {
  return request({
    url: '/erp/user',
    method: 'get',
    params: data,
  })
}

export function doEdit(data) {
  return request({
    url: '/erp/auth/doEdit',
    method: 'post',
    data,
  })
}

export function doDelete(data) {
  return request({
    url: '/erp/user/delete/' + data,
    method: 'delete',
  })
}

export function updatePwd(data) {
  return request({
    url: '/erp/user/resetPwd',
    method: 'put',
    data
  })
}

export function updateLocked(data) {
  return request({
    url: '/erp/user/updateLocked/' + data,
    method: 'put',
  })
}

